<div class="panel"><strong>My Grades</strong></div>
<?if(isset($system_message))echo $system_message;?>
<!-- <table class="data-table">
		<thead class="tabular-head">
		<tr>
			<th>Subject Code</th>
			<?// if(!empty($grading_periods)) :?>
			<?// foreach($grading_periods as $row) :?>
			<th><?//= $row->gp_desc ;?></th>
			<?// endforeach ;?>
			<?// endif ;?>
		</tr>
		</thead>
		<tbody class="tabular">
  <?// if(!empty($student_grades)) :?>
  <?// foreach($student_grades as $row) :?>
			<tr>
				<td><?//= $row->subj_code ;?></td>
				<?// foreach($grades as $r) :?>
				<?// if($r->subject_id == $row->subj_id) :?>
				<td><?//=  $r->value;?><br /><?//= $r->remarks ;?></td>
				<?// endif ;?>
				<?// endforeach ;?>
			</tr>
		<?// endforeach ;?>
  <?// else: ?>
			<tr>
				<th colspan=10 align=center>-- No Grades --</th>
			</tr>
  <?// endif;?>
  </tbody>
</table> -->
<table class="table table-bordered">
			<thead class="tabular-head">
			<tr>
				<th>Subject Code</th>
				<? if(!empty($grading_periods)) :?>
				<? foreach($grading_periods as $row) :?>
				<th style="text-align:center;"><?= ucfirst(strtolower($row->gp_desc)) ;?></th>
				<? endforeach ;?>
				<? endif ;?>
			</tr>
			</thead>
			<tbody class="tabular">
      <? if(!empty($student_grades)) :?>
      <? foreach($student_grades as $row) :?>
		<?php
  			/** COMPUTE FOR FINAL GRADE ONLY WHEN ALL GRADING PERIOD EXIST OR HAS GRADE **/
  			$final_grade = 0;
  			$grade_total = 0;
  			$gp_ctr = 0;
  			$gp_total = count($grading_periods);
  		?>
			    <tr>
				    <td><?= $row->subj_code ;?></td>
				    <? foreach($grades as $r) :?>
				    <? if($r->subject_id == $row->subj_id) :?>
					<?php
						if($r->value){
							$gp_ctr++;
							$grade_total += floatval($r->value);
						}
					?>
				    <td style="text-align:center;">
						<?if(isset($student_profile) && strtolower($student_profile->level_code) !== "pre-kinder"):?>
							<div class="btn-group">
							  <button type="button" class="btn btn-mini btn-primary"><?=_convert($r->value)?></button>
							  <button type="button" class="btn btn-mini btn-success"><?=$r->value?></button>
							</div>
						<?else:?>
							<?=_convert($r->value)?>
						<?endif;?>
					</td>
				    <? endif ;?>
				    <? endforeach ;?>
			    </tr>
			<? endforeach ;?>
      <? else: ?>
			    <tr>
				    <th colspan="<?=count($grading_periods)+1;?>">-- Either grades is not yet available or you dont have permission to view --</th>
			    </tr>
      <? endif;?>
      </tbody>
  </table>

  <div><a href="#" data-reveal-id="gradeTable" class="btn btn-mini">show grading table</a></div>
  
<!-- grade table modal -->
<div id="gradeTable" class="reveal-modal" style="margin-top:-10%;">
  <a class="close-reveal-modal btn btn-danger">&#215;</a>
  <?$this->load->view('layouts/_grading_table');?>
</div>
<!-- <div class="alert-box secondary">
	This Page is Currently under development.
</div> -->
